/**
	@file	Token.h
	@date	2010/09/08
	@author sang-soo kim
	@brief  간략한 word token을 저장하는 class
*/
#if !defined(__TOKEN_H__)
#define __TOKEN_H__
#pragma once
#include <stdint.h>
#include <string>
#include <algorithm>

class Token
{
protected:
    const char * m_pLinePtr;
	uint8_t length;
public:
	uint8_t type;
	Token() : m_pLinePtr(NULL), length(0), type(0)
    {};
	virtual ~Token() {};
 
    /** 
    * constructor
    */
    virtual void clear()
    {
        m_pLinePtr = NULL;
        length =0;
    }
    virtual void setValue( const char * ch, uint8_t len)
    {
        m_pLinePtr  =   ch;
        length      = len;
    }
    /**
    *   operator =
    */
    virtual Token operator = ( const Token obj) 
    {
        m_pLinePtr  = obj.m_pLinePtr;
        length      = obj.length;
        return * this;
    }
    virtual std::string getString(bool flag = false) 
    {
        if( m_pLinePtr == NULL) return "";
        std::string tmp = "";
        for(int i=0;i< length; i++)
        {
            tmp = tmp + *(m_pLinePtr+i);
        }

        if( flag == true)
            std::transform(tmp.begin(), tmp.end(),tmp.begin(), ::toupper);
        return tmp;
    }
    void setCharPtr(const char * ptr) 
    {
        m_pLinePtr = ptr;
    }
    const char * getCharPtr() 
    {
        return m_pLinePtr;
    }
    void setLength( uint8_t len)
    {
        length = len;
    }
    uint8_t getLength()
    {
        return (uint8_t)length;
    }
};

#endif


